package com.example.demo.controller;

import com.example.demo.domain.po.BookTypeEntity;
import com.example.demo.service.BookTypeService;
import com.example.demo.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/bookType")
public class BookTypeController {
    @Autowired
    private BookTypeService bookTypeService;
    @PostMapping("/getAllBookType")
    public R getBookTypes() {
        List<BookTypeEntity> entitys = bookTypeService.getBookTypes();
        return R.success(entitys);
    }

    @PostMapping("/deleteBookType")
    public R deleteBookType(@RequestBody BookTypeEntity bookTypeEntity) {
        int x = bookTypeService.deleteBookType(bookTypeEntity);
        String 	str = "update success";
        return R.success(str);
    }
    @PostMapping("/addBookType")
    public R addBookType(@RequestBody BookTypeEntity bookTypeEntity){
        BookTypeEntity entity = bookTypeService.addBookType(bookTypeEntity);
        return R.success(entity);
    }
}
